Function: c-before-change-check-<>-operators

c-before-change-check-<>-operators is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-before-change-check-<>-operators BEG END)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-before-change-check-<>-operators (beg end)
  ;; Unmark certain pairs of "< .... >" which are currently marked as
  ;; template/generic delimiters.  (This marking is via syntax-table text
  ;; properties), and expand the (c-new-BEG c-new-END) region to include all
  ;; unmarked < and > operators within the certain bounds (see below).
  ;;
  ;; These pairs are those which are in the current "statement" (i.e.,
  ;; the region between the {, }, or ; before BEG and the one after
  ;; END), and which enclose any part of the interval (BEG END).
  ;;
  ;; Note that in C++ (?and Java), template/generic parens cannot
  ;; enclose a brace or semicolon, so we use these as bounds on the
  ;; region we must work on.
  ;;
  ;; This function is called from before-change-functions (via
  ;; c-get-state-before-change-functions).  Thus the buffer is widened,
  ;; and point is undefined, both at entry and exit.
  ;;
  ;; FIXME!!!  This routine ignores the possibility of macros entirely.
  ;; 2010-01-29.
  (when (and (or (> end beg)
		 (and (> c-<-pseudo-digraph-cont-len 0)
		      (goto-char beg)
		      (progn
			(skip-chars-backward
			 "^<" (max (- (point) c-<-pseudo-digraph-cont-len)
				   (point-min)))
			(eq (char-before) ?<))
		      (looking-at c-<-pseudo-digraph-cont-regexp)))
	     (or
	      (progn
		(goto-char beg)
		(search-backward "<" (max (- (point) 1024) (point-min)) t))
	      (progn
		(goto-char end)
		(search-forward ">" (min (+ (point) 1024) (point-max)) t))))
    (save-excursion
      (c-save-buffer-state
	  ((beg-lit-start (progn (goto-char beg) (c-literal-start)))
	   (end-lit-limits (progn (goto-char end) (c-literal-limits)))
	   new-beg new-end beg-limit end-limit)
	;; Locate the earliest < after the barrier before the changed region,
	;; which isn't already marked as a paren.
	(goto-char (or beg-lit-start beg))
	(setq beg-limit (c-determine-limit 512))

	;; Remove the syntax-table/category properties from each pertinent <...>
	;; pair.  Firstly, the ones with the < before beg and > after beg....
	(while (progn (c-syntactic-skip-backward "^;{}<" beg-limit)
		      (eq (char-before) ?<))
	  (c-backward-token-2)
	  (when (eq (char-after) ?<)
	    (c-clear-<-pair-props-if-match-after beg)
	    (setq new-beg (point))))
	(c-forward-syntactic-ws)

	;; ...Then the ones with < before end and > after end.
	(goto-char (if end-lit-limits (cdr end-lit-limits) end))
	(setq end-limit (c-determine-+ve-limit 512))
	(while (and (c-syntactic-re-search-forward "[;{}>]" end-limit 'end)
		    (eq (char-before) ?>))
	  (c-end-of-current-token)
	  (when (eq (char-before) ?>)
	    (c-clear->-pair-props-if-match-before end (1- (point)))
	    (setq new-end (point))))
	(c-backward-syntactic-ws)

	;; Extend the fontification region, if needed.
	(and new-beg
	     (< new-beg c-new-BEG)
	     (setq c-new-BEG new-beg))
	(and new-end
	     (> new-end c-new-END)
	     (setq c-new-END new-end))))))